--
-- Author:      feilong
-- DateTime:    2019-04-30 10:59:15
-- Description: 节点信息

local skynet = require("skynet")


local ServerInfo = class("ServerInfo")

function ServerInfo:ctor()
    self.id = 0			 --服务器id
    self.type = ""		 --服务器类型
    self.port = 0 		 --服务器对外socket port
    self.wport = 0		 --服务器对外websocket port
    self.name  = "" 	 --服务名
    self.cluster_addr = nil --在集群地址
    self.max_client_num = 1000  --最大客户端数
    self.cur_client_num = 0     --在线数    

    self:init()
end

function ServerInfo:init()
    self.id = tonumber(skynet.getenv("server_id"))
    self.type = skynet.getenv("server_type")
    self.name = skynet.getenv("server_name")
    self.cluster_addr = skynet.getenv("cluster_addr")
    
end

function ServerInfo:reset()
    self.id = 0			 --服务器id
    self.type = ""		 --服务器类型
    self.port = 0 		 --服务器对外socket port
    self.wport = 0		 --服务器对外websocket port
    self.name  = "" 	 --服务名
    self.cluster_addr = nil --在集群地址    
    self.max_client_num = 1000  --最大客户端数
    self.cur_client_num = 0     --在线数 	
end

function ServerInfo:setData(data)
	for k, v in pairs(data) do 
		self[k] = v
	end
end

function ServerInfo:getData()
	local data = {}
	data.id = self.id
	data.type = self.type
	data.port = self.port
	data.name = self.name	
	data.cluster_addr = self.cluster_addr
	data.max_client_num = self.max_client_num
	data.cur_client_num = self.cur_client_num		
	return data
end

function ServerInfo:getId()
	return self.id
end

function ServerInfo:getType()
	return self.type
end

function ServerInfo:getName()
	return self.name
end

function ServerInfo:getPort()
	return self.port
end

function ServerInfo:getClusterAddr()
	return self.cluster_addr
end

function ServerInfo:getMaxClientNum()
	return self.max_client_num
end

function ServerInfo:getCurClientNum()
	return self.cur_client_num
end









return ServerInfo